<?php

namespace App\Listeners;

use App\Events\WxLoginEvent;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;

class IntegratesListener implements ShouldQueue
{
//    public $connection = 'database';
    /**
     * 任务将被发送到的队列的名称。
     *
     * @var string|null
     */
    public $queue = 'wxlogin';
    /**
     * 任务被处理的延迟时间（秒）。
     *
     * @var int
     */
    public $delay = 0;
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  \App\Events\WxLoginEvent  $event
     * @return void
     */
    public function handle(WxLoginEvent $event)
    {
        sleep(10/0);
        dump($event->user->nickname);
    }

    public function failed(WxLoginEvent $event, \Throwable $e)
    {
            Log::info($this->queue.'队列报错了',[$e->getMessage(),$e->getLine(),$e->getFile()]);
    }
}
